import { createStore } from "vuex";
import { dxget, routeSwitch } from "../util/index";
export default createStore({
  state: {
    IfTheFullScreen: "", // 是否全屏显示
    WhetherNot: false, //左侧菜单是否缩小
    currentMenu: null, //左侧菜单 当前选中
    browsingHistory: [], //用户浏览记录
    dialogVisibleImg: false, // 是否显示上传图片
    lyName: "",
    storequery:"",
    isjxdfd:false,
    keepAlive: [
      "index",
      "keyword",
      "winnersList",
      "newShare",
      "ShortTermAssistant",
      "conceptOfPlate",
      "observationArea",
      "videoqita",
      "videoxl",
      "sentiment",
      'djbjnewsTrends',
      'hnlqnewList',
      'xjyxproductManagement',
      "hhorderManagementList",
      'hhcompleted',
      'hhunfinished'
    ],
    routerName: "", // 当前路由的名称
    currentTime: 0, // 当前的时间戳
    currentTimeOnes: 0,
    windowSize: 1920,
    windHeight: 0,
    msgList: [],
    ReceiveMessage: 0, //接手到消息的时间戳
    msgFrom: "",
    OpenTheMenu: true,
    isheader: true,
    tableLoad: false,
    lsInfo: [], // 因获取全部股票太卡了，借个参数预加载
    routerList: [],
    menumgList: null,
    rolemanagement: null, //权限列表
    accountType:'',
    ddmJsonData:[],
    ddmdqobj:{}
  },
  mutations: {
    isOpenTheMenu(state) {
      if (state.windowSize > 760) {
        return;
      }
      state.OpenTheMenu = false;
    },
    // 路由下拉列表
    setrouterList(state, data) {
      const arrList = [];
      data.map((a) => {
        arrList.push({
          label: a.meta.title,
          value: a.path,
          name: a.name,
        });
      });
      state.routerList = arrList;
    },
    async setmenumg(state) {
   
      if(localStorage.menumgList){
       try{
        return  state.menumgList= JSON.parse(localStorage.menumgList)
       }catch(e){

       }
      }
      if (!state.menumgList) {
        const { data }: any = await dxget("dxgjAdmin/menumg", {
          usertype: localStorage.usertype,
        });
        state.menumgList = routeSwitch(data);
        try{
          localStorage.menumgList = JSON.stringify(routeSwitch(data))
        }catch(e){
          
        }
      }
    },
    setrolemanagement(state, data) {
      if (localStorage.rolemanagement) {
        state.rolemanagement = localStorage.rolemanagement.split(",");
      } else if (data) {
        state.rolemanagement = data.split(",");
      }
    },
  },
  actions: {},
  modules: {},
});
